<?php
$model_roles = new Admin_Model_Roles();
$this->headTitle('Quản lý người dùng', 'append');
?>
<div class="grid grid_8">
    <div class="box-header">
        Danh sách người dùng
        <a class="add" href="<?php echo $this->url(array('controller'=>'users', 'action'=>'add'));?>">
            Thêm mới
        </a>
    </div>
    <div class="box table">
        <table cellspacing="0">
        	<thead>
        		<tr>
        			<td class="tc">ID</td>
        			<td class="tc">Tên tài khoản</td>
        			<td class="tc">Quyền</td>
        			<td class="tc">Trạng thái</td>
        			<td class="tc">Tuỳ chọn</td>
        		</tr>
        	</thead>
        	<tbody>
                <?php
                    foreach ($this->users_list as $user){
                ?>
                    <tr>
            			<td class="tc"><?php echo $this->escape($user->userId); ?></td>
            			<td>
                            <a href="<?php echo $this->url(array('controller'=>'users', 'action'=>'edit', 'id'=>$user->userId));?>" title="Sửa thông tin">
                                <?php echo $this->escape($user->username); ?>
                            </a>
                        </td>
            			<td>
                            <?php
                    			$data = $model_roles->getRolesUser($user->userId);
                				foreach($data as $role){
                	                echo $this->escape('- '.$role->roleName);
                	                echo '</br>';
                	            }
                            ?>
                        </td>
                        <td class="tc">
                            <?php
                                if($user->status == 1){
                                    echo '<img src="image/icons/small/icon_check.png" alt="Đang hoạt động" title="Đang hoạt động" border="0"/>';
                                }else{
                                    echo '<img src="image/icons/small/icon_uncheck.png" alt="Đã Khóa" title="Đã khóa" border="0"/>';
                                }
                            ?>
                        </td>
            			<td class="tc"> 
                            <a href="<?php echo $this->url(array('controller'=>'users', 'action'=>'edit', 'id'=>$user->userId));?>" title="Sửa thông tin">
                                <img src="image/icons/small/icon_edit.png" alt="edit user" border="0"/>
                            </a>
                            <?php if($this->users_check['userId'] != $user->userId) { ?>
                			<a href="<?php echo $this->url(array('controller'=>'users', 'action'=>'delete', 'id'=>$user->userId));?>" title="Xóa người dùng">
                                <img src="image/icons/small/icon_delete.png" alt="delete user" border="0"/>
                            </a>
                            <?php } ?>
                        </td>
                    </tr>
                <?php
                    }
                ?>
            </tbody>
        </table>
    </div>
</div>
<div class="grid grid_4">
    <div class="box-header">Hướng dẫn</div>
    <div class="box">
    </div>
</div>
